source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

set nocompatible              " be iMproved, required
filetype off                  " required

set rtp+=$VIM/vimfiles/bundle/Vundle.vim/
call vundle#begin('$VIM/vimfiles/bundle/')
Bundle 'gmarik/vundle.vim'
Bundle "bufexplorer.zip"
Bundle "a.vim"
Bundle 'mattn/emmet-vim'
Bundle 'skywind3000/quickmenu.vim'
Bundle 'EnhCommentify.vim'
call vundle#end()            " required
filetype plugin indent on    " required

set diffexpr=MyDiff()

function MyDiff()
  let opt = '-a --binary '
  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 = v:fname_in
  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg2 = v:fname_new
  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg3 = v:fname_out
  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  if $VIMRUNTIME =~ ' '
    if &sh =~ '\<cmd'
      if empty(&shellxquote)
        let l:shxq_sav = ''
        set shellxquote&
      endif
      let cmd = '"' . $VIMRUNTIME . '\diff"'
    else
      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
    endif
  else
    let cmd = $VIMRUNTIME . '\diff'
  endif
  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
  if exists('l:shxq_sav')
    let &shellxquote=l:shxq_sav
  endif
endfunction

colo desert
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
set langmenu=zh_CN.UTF-8
set guifont=Courier:h18:cANSI

set syntax=on
set ignorecase

set autoindent
set nobackup

set cindent

set smartindent

set softtabstop=4
set shiftwidth=4
set wrap
set linebreak

set number
set showmatch

set hlsearch
set incsearch

set matchtime=5

set showmatch

set history=1000
"关闭右边滚动条
set guioptions-=r 
"自动将当前文件所在目录设置为当前工作目录
set autochdir
filetype on
filetype indent on
filetype plugin on
filetype plugin indent on
set nocp

" ctags
map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR><CR>
set tags+=D:\work\code\STM32F0xx_StdPeriph_Lib\Libraries\tags


"quickmenu
" choose a favorite key to show/hide quickmenu 
if 1 
	call quickmenu#reset()
	call quickmenu#append('#yongnuo', '')
	call quickmenu#append('YN968N', 'e d:/work/code/YN968N/TTL/YN-968N-TTL/main.c', '')
	call quickmenu#append('YN968C', 'e d:/work/code/YN668EX/TTL/APP/main.c', '')
	call quickmenu#append('YN622C-TX-156', 'e d:/work/code/YN622C-TX/SIM3U156/YN-622C-Controller/main.c', '')
	call quickmenu#append('YN622C-TX-STM', 'e d:/work/code/YN622C-TX/STM32F072/APP/main.c', '')
	call quickmenu#append('YN622N-TX-156', 'e d:/work/code/YN622N-TX/SIM3U156/YN-622N-Controller/main.c', '')
	call quickmenu#append('YN622N-TX-STM', 'e d:/work/code/YN622N-TX/STM32F072/APP/main.c', '')
	call quickmenu#append('#practice', '')
	call quickmenu#append('Navigation', 'e e:/PersonalCode/front_end/navigation/index.html', '')
	nnoremap <F12> :call quickmenu#toggle(0)<cr>
endif
noremap <silent><F12> :call quickmenu#toggle(0)<cr> 
" enable cursorline (L) and cmdline help (H) 
let g:quickmenu_options = "LH"

"html -> css
function! JumpToCSS()
  let id_pos = searchpos("id", "nb", line('.'))[1]
  let class_pos = searchpos("class", "nb", line('.'))[1]

  if class_pos > 0 || id_pos > 0
    if class_pos < id_pos
      execute ":vim '#".expand('<cword>')."' **/*.css"
    elseif class_pos > id_pos
      execute ":vim '.".expand('<cword>')."' **/*.css"
    endif
  endif
endfunction
"nnoremap <F9> :call JumpToCSS()<CR>
"添加符合'-',配合css类搜索
set iskeyword+=-

let g:ctrlp_map = '<c-p>'

" map in insert mode
imap <c-d> <esc>ddi
imap <M-c> <Esc><Plug>Traditionalji

"autocmd
let maplocalleader = "-"
"最大化屏幕
autocmd GUIEnter * simalt ~x
autocmd FileType javascript nnoremap <buffer> cc I//<esc>
autocmd FileType c nnoremap <buffer> cc I//<esc>
autocmd FileType python nnoremap <buffer> cc I#<esc>
autocmd FileType vimrc nnoremap <buffer> cc I"<esc>
autocmd FileType html noremap <c-]> :grep "\<<cword>\>" *.css<CR><CR>
